/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package cryptography;

import java.io.*;
import java.math.BigInteger;

/**
 *
 * @author Mouchicc 1
 */
public class GUI_Test {

    public static void main(String[] args) {
/*
        String path = "/Users/Najima/Documents/Mourad PWS/caesar.txt";
        String s = "123";

        BigInteger p = new BigInteger("45");
        BigInteger q = new BigInteger("65");
        BigInteger publickey = new BigInteger("3");

        RSA enc = new RSA(p, q, publickey);
        BigInteger[] cyphertext = enc.encode(s);
        System.out.println();
        System.out.println("Encoded Text, computed with RSA:");
        for (int i = 0; i < cyphertext.length; i++) {
            System.out.println("     " + cyphertext[i]);
        }

        RSA dec = new RSA(enc.mod, enc.privateKey);
        String plaintext = dec.decode(cyphertext);
        System.out.println();
        System.out.println("Decoded Text, computed with RSA:");
        System.out.println("     " + plaintext);
        * 
        */

        String in_path = "C:/caesar_arcanum_enc.txt";
        String out_path = in_path.replaceAll("enc", "dec");
        String sub = in_path.substring(0, in_path.length() - 4);
        
        String first = out_path.split("_")[0] + ".txt";
        
        System.out.println(sub);

        
    }

    public static String bitoString(BigInteger[] bis) {
        StringBuffer sb = new StringBuffer();
        for (int i = 0; i < bis.length; i++) {
            sb.append(bis[i] + " ");
        }
        return sb.toString();
    }

    public static BigInteger[] stringtoBI(String s) {
        String[] splitted = s.split(" ");
        BigInteger[] out = new BigInteger[splitted.length];
        for (int i = 0; i < splitted.length; i++) {
            out[i] = new BigInteger(splitted[i]);
        }
        return out;
    }

    public static String readFile(String path) {
        String s = "";
        StringBuilder contents = new StringBuilder();
        File file = new File(path);
        FileInputStream fis = null;
        BufferedInputStream bis = null;
        DataInputStream dis = null;

        try {
            fis = new FileInputStream(file);
            bis = new BufferedInputStream(fis);
            dis = new DataInputStream(bis);

            while (dis.available() != 0) {
                s = dis.readLine();
                contents.append(s);
                contents.append(System.getProperty("line.separator"));
            }
            contents.deleteCharAt(contents.length() - 1);

            fis.close();
            bis.close();
            dis.close();

        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return contents.toString();
    }
}
